package com.qingcheng.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.qingcheng.dao.TradingMapper;
import com.qingcheng.pojo.order.Trading;
import com.qingcheng.service.order.TradingService;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;
@Service(interfaceClass = TradingService.class)
public class TradingServiceImpl implements TradingService {

    @Autowired
    private TradingMapper tradingMapper;


    /**
     * 定义根据日期查询当天交易的方法
     * @param localDate
     * @return
     */
    @Override
    public Trading findTranding(LocalDate localDate) {
        //获取交易对象
        Trading trading = tradingMapper.findTrading(localDate);
        //设置浏览人数
        trading.setViews(500);
        //设置交易相关人数
        trading.setTotalOrderMan(100);
        trading.setMidOrderMan(50);
        //设置客单价
        trading.setAvgPrice(trading.getRealOrderMoney()/trading.getMidOrderMan());
        return trading;
    }
}
